package com.binance.healthcenter.common;

import org.springframework.http.HttpStatus;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.web.client.ResponseErrorHandler;

import java.io.IOException;
/**
 * 决定到底那儿些异常要返回，那儿些忽略
 * */
public class RestTemplateErrorHandler implements ResponseErrorHandler {
    @Override
    public boolean hasError(ClientHttpResponse clientHttpResponse) throws IOException {
        HttpStatus httpStatus= clientHttpResponse.getStatusCode();
        if(httpStatus.is5xxServerError()){
            return false;
        }else{
            return true;
        }
    }

    @Override
    public void handleError(ClientHttpResponse clientHttpResponse) throws IOException {

    }
}
